package com.yc.snacknet_vue.biz.Impl;

import java.util.List;

import com.yc.snacknet_vue.bean.MemberInfo;
import com.yc.snacknet_vue.biz.IMemberInfoBiz;
import com.yc.snacknet_vue.dao.IMemberInfoDAO;
import com.yc.snacknet_vue.dao.impl.MemberInfoDAOImpl;
import com.yc.snacknet_vue.utils.StringUtil;

/**
 * 会员业务层 实现
 * company 源辰信息
 * @author 38929
 * @date 2021年8月6日
 * @version 1.0
 * Email 1198865589@qq.com
 */
public class MemberInfoBizImpl implements IMemberInfoBiz{
	@Override
	public MemberInfo login(MemberInfo mem) {
		//数据验证
		if( null == mem || StringUtil.checkNull( mem.getNickName(), mem.getPwd())) {
			return null;
		}
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.login(mem);
	}

	@Override
	public List<MemberInfo> finds(MemberInfo mem, int page, int rows) {
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.finds(mem, page, rows);
	}

	@Override
	public int totals(MemberInfo mem) {
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.totals(mem);
	}

	//添加用户
	@Override
	public int add(MemberInfo mem) {
		if( null == mem || StringUtil.checkNull(mem.getNickName(),mem.getPwd(), 
				mem.getTel(),mem.getEmail())) {
			return -1;
		}
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.add(mem);
	}

	//修改重置密码
	@Override
	public int update(String mno) {
		if( null == mno) {
			return -1;
		}
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.update(mno);
	}

	//修改用户状态
	@Override
	public int delete(String status, String mno) {
		if( StringUtil.checkNull(status, mno)) {
			return -1;
		}
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.delete(status, mno);
	}

	//用户注册
	@Override
	public int reg(String nickName, String pwd, String email, String tel) {
		if( StringUtil.checkNull(nickName, pwd, email, tel)) {
			return -1;
		}
		IMemberInfoDAO dao = new MemberInfoDAOImpl();
		return dao.reg(nickName, pwd, email, tel);
	}
}
